package com.example.learnandroid;


import com.example.ListView.ListFruitActivity;
import com.example.ListView.ListMobileActivity;
import com.example.test.ListViewTest;

import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.Toast;

public class MainActivity extends Activity {
	ImageView imageView;
	MenuItem menuitem1;
	private final Context context = this;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		imageView = (ImageView) findViewById(R.id.imageview);
		Bitmap bg = BitmapFactory.decodeResource(getResources(), R.drawable.background);
		imageView.setImageBitmap(bg);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		menu.clear();
		menuitem1 = menu.add("GUI");
		return true;
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		
		if(item == menuitem1){
			chooseListAction();
		}

		return true;
	}
	public void chooseListAction(){
		AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(  
				context);
 
			// set title
			alertDialogBuilder.setTitle("Choose a action");
			CharSequence items[] = {"Set new BG","Make GIF 1","Seek Bar","Make GIF 2","Normal List View","Custom List View","Test Something","Make GIF 3"};
			
			// set dialog message
			alertDialogBuilder.setTitle("Choose a task")
	           .setItems(items, new DialogInterface.OnClickListener() {
	               public void onClick(DialogInterface dialog, int which) {
	               // The 'which' argument contains the index position
	               // of the selected item
	            	switch(which){
		            	case 0:
		            		Intent intent1 = new Intent(MainActivity.this, SetBG.class);
		                    startActivity(intent1);
		            		break;
		            	case 1:
		            		Intent intent2 = new Intent(MainActivity.this, MakeGIF.class);
		                    startActivity(intent2);
		            		break;
		            	case 2:
		            		Intent intent3 = new Intent(MainActivity.this, SeekBarExample.class);
		                    startActivity(intent3);
		            		break;
		            	case 3:
		            		Intent intent4 = new Intent(MainActivity.this, MakeGIF_v2.class);
		                    startActivity(intent4);
		            		break;
		            	case 4:
		            		Intent intent5 = new Intent(MainActivity.this, ListFruitActivity.class);
		                    startActivity(intent5);
		            		break;
		            	case 5:
		            		Intent intent6 = new Intent(MainActivity.this, ListMobileActivity.class);
		                    startActivity(intent6);
		            		break;	
		            	case 6:
		            		Intent intent7 = new Intent(MainActivity.this, ListViewTest.class);
		                    startActivity(intent7);
		            		break;
		            	case 7:
		            		Intent intent8 = new Intent(MainActivity.this, MakeGIF_v3.class);
		                    startActivity(intent8);
		            		break;
		            		
		            	default:
		            			break;  
	          
	            	}
	            	   
	           }
	           });
				
 
				// create alert dialog
				AlertDialog alertDialog = alertDialogBuilder.create();
 
				// show it
				alertDialog.show();
	}
}
